<template>
    <div class="personnelAdd">

        <el-breadcrumb separator="/" class="ml_5">
            <el-breadcrumb-item :to="{ path: '/' }">
                <i class="lh lh-seller fw_100"></i>
            </el-breadcrumb-item>
            <el-breadcrumb-item>帮助中心</el-breadcrumb-item>
            <el-breadcrumb-item>新增帮助</el-breadcrumb-item>
        </el-breadcrumb>

        <div class="content_Box box-shadow mt_15 px_10">
            <h4 class="border-bottom pb_10 mb_20">新增</h4>
            <el-form label-width="100px" class="mw_400">
                <el-form-item label="所属板块" :required="true">
                    <el-select class="w_100p"
                        v-model="type_arr"
                        placeholder="请选择"
                        @change="changeBtndialogtype"
                    >
                        <el-option
                            v-for="item in demandList"
                            :key="item.id"
                            :label="item.label_name"
                            :value="`${item.id}|${item.label_name}`"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="所属类别" :required="true">
                    <el-select class="w_100p"
                        v-model="type_arr"
                        placeholder="请选择"
                        @change="changeBtndialogtype"
                    >
                        <el-option
                            v-for="item in demandList"
                            :key="item.id"
                            :label="item.label_name"
                            :value="`${item.id}|${item.label_name}`"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="帮助主题" :required="true">
                    <el-input v-model="address"></el-input>
                </el-form-item>
                <el-form-item label="封面图">
                    <uploadedit pic_name="'logo'" :pic_url="logo" @func="img5"></uploadedit>
                </el-form-item>
                <el-form-item label="跳转地址" :required="true">
                    <el-input v-model="address"></el-input>
                </el-form-item>
               <el-form-item label="排序" :required="true">
                    <el-input v-model="address"></el-input>
                </el-form-item>
                <el-form-item label="发布状态" :required="true">
                    <el-switch
                        v-model="work_status_tag"
                        active-color="#13ce66"
                        inactive-color="#ff4949">
                    </el-switch>
                </el-form-item>
                <el-form-item label="备注">
                        <el-input
                            type="textarea"
                            :rows="8"
                            :cols="44"
                            placeholder="请输入内容"
                            v-model="remark"
                        ></el-input>
                </el-form-item>

                <el-form-item class="my_20">
                    <el-button round type="success" @click="submitBtn">提交</el-button>
					<el-button round @click="back">返回</el-button>
                </el-form-item>
            </el-form>

        </div>
    </div>
</template>

<script>
var common = require("../../../static/tool.js");
import { mainfun } from "../../../assets/js/main.js";
export default {
    name: "HelpAdd",
    data() {
        return {
            windowSizeHeight: document.documentElement.clientHeight, //浏览器可视化窗口的大小
            screenHeight: document.documentElement.clientHeight,
            manageInfo: JSON.parse(sessionStorage.getItem("manageInfo")), //登录信息
            url: common.url,
        };
	},
	computed: {

	},
    created() {

    },
    mounted() {

    },
    methods: {
        submitBtn() {
            // 新增以及修改的接口
            if (
                this.shop_name == "" ||
                this.label_name == "" ||
                this.label_id == "" ||
                this.price_b == "" ||
                this.price_c == "" ||
                this.neednum == "" ||
                this.timelong == "" ||
                this.address == "" ||
                this.start_time == "" ||
                this.end_time == "" ||
                this.kg_start_time == ""
            ) {
                this.$message.error("请填写必填项");
                return;
            }
            let fn = new FormData();
            if(this.shop_name==""){
                this.shop_id = "";
            }
            fn.append("shop_id", this.shop_id);
            fn.append("shop_sn", this.shop_sn);


            this.$http.post(this.url + "/demand/save", fn).then(
                (res) => {
                    // console.log(res);
                    if (
                        res.data.msg == "操作成功！" ||
                        res.data.code == "200"
                    ) {
                        this.$message.success(res.data.msg);
                        this.back();
                    } else if (res.data.code == "8886") {
                        //code   8886  登录过期
                        sessionStorage.clear();
                        this.$alert("登录已过期，请重新登录 !", "提示", {
                            confirmButtonText: "确定",
                            callback: (action) => {
                                window.location = "login.html";
                            },
                        });
                        return;
                    } else {
                        this.$message.error(res.data.msg);
                        return;
                    }
                },
                (res) => {
                    this.$message.error("网络错误！");
                    return;
                }
            );
        },
        back() {
            //返回
            this.$router.go(-1);
        },
        img5(data) {
            // console.log(data);
            this.logo = data;
		},
    }
};
</script>

<style scoped>
.row-info {
    padding: 10px 0;
}
.resetBtn,
.btnOK {
    padding: 0 30px;
}
.title-key {
    width: 100px;
}
.list-cont img {
    width: 128px;
}
</style>



// WEBPACK FOOTER //
// src/components/helpcenter/HelpAdd.vue